package com.wu.controller;

import com.wu.mapper.MenuMapper;
import com.wu.pojo.Menu;
import com.wu.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class menuController {

    @Autowired
    private MenuMapper menuMapper;

    @Value("${server.port}")
    private String port;

    @GetMapping("/index")
    public String index(){
        return this.port;
    }

    @GetMapping("/findall/{index}/{limit}")
    public MenuVo findAll(@PathVariable("index") int index,@PathVariable("limit") int limit){
        //1.由于Layui框架的数据格式，所以我们要对这个进行一个封装
        MenuVo menuVo = new MenuVo();
        menuVo.setCode(0).setMsg("数据格式有误").setCount(100).setData(menuMapper.findAll(index, limit));
        return menuVo;

    }
}
